Kubernetes - pods
The Architecture of K8s
What is a Kubernetes Cluster?
This is practically everything in the image above. A cluster is a group of Nodes (aka worker machines), the Nodes Run containerized applications within each Pod.
The Cluster can be accessed VIA:
UI (eg: GKE dashboards),
Or a CLI, most commonly kubectl
, for Minikube (a local single node cluster), they use minikube kubectl --
What are Nodes?
As you can see in the image above, there are 3 nodes,
- K8s Master Node
- K8s Worker Node 1
- K8s Worker Node 2
A node is practically a virtual or physical machine (depending on the cluster)
there are two types of Nodes in a cluster:
-
The Master Node, there is always only 1 of these in any cluster, it is reserved for the cluster so nothing runs on this, it is like the Control plane for the Cluster, to change item inside the cluster you need to go through the Api Server. In some special clusters, there might not be a Master Node, such as Minikube which is a single node cluster.
-
The Worker Nodes, this is where all the pods will be located in, Each worker node is controlled by the control plane which is in the Master Node, they all have a unique internal Ip address, A cluster can have Several Worker Nodes.
What is the Kubelet?
In very simple terms, the kubelet registers the node with the api server and keeps checking with the PodSpec (A YAML or JSON object that describes a pod) to see if the Pod’s Containers are running healthy
What is the Kube-Proxy?
It’s a network Proxy that runs on each node in the cluster, it monitors the changes to Services and their endpoints and maintains network rules on the node to forward traffic correctly to the pods
What is a Pod?
Inside the WorkerNodes, you can see that there are quite a few pods,
inside each pod there is a group of containers that share storage, network resources and a specification on how to run the containers.
the pods are seen as disposable, so you would rarely create a single pod, if a pod fails, then it is shut down and another one is created in a blue green deployment fashion, Usually in a Pod, there is one Main container and the other’s are just support containers for the Main one. Most commonly there is just one container per pod
What is a Service?
A Service is a method for exposing a network application that is running as one or more Pods in your cluster. As we said above, Pods are disposable, so when a new pod comes with a new IP, it will be a nightmare for other Pods/Services to talk with it.
there are three different type you need to know.
Service Type: NodePorts
It listens to requests on a specific port within the node and forwards the request to the port of a Pod that is running the containers
It is kind of like a Gateway into the worker Nodes.
Service Type: ClusterIP
This exposes a POD so that traffic can flow into if from other Pods, it is isolated from the outside world (anything outside the cluster can’t reach it) and it can only talk to other ClusterIPs, or any other Service inside the pod (INC other NodePorts or LBs),
Service Type: LoadBalancer
this is an alternative to the NodePort, except it is more powerful and intended for much heavier load, although it could get Really Costly
It exposes your node to the Outside world and directs traffic to the specified pods and also acts as a Load balancer by sending traffic equally to multiple replica pods.